import req from '../utils/request';
import * as url from '../constants/api';

/**
 * @returns { Promise<{ message: string, data: object }> }
 * @description 获取我的频道列表
 */
export function getMyChannels () {
    return req({
        url: url.USER_CHANNELS,
        method: 'GET',
    });
}

/**
 * @param { Array<{ id: string, seq: string }> } channels
 * @returns { Promise<{ message: string, data: object }> }
 * @description 保存我的频道列表
 */
export function saveMyChannels (channels) {
    return req({
        url: url.USER_CHANNELS,
        method: 'PUT',
        data: {
            channels,
        },
    });
}

/**
 * @param { string } id
 * @returns { Promise<{ message: string, data: object }> }
 * @description 删除我的频道
 * @summary to remove
 */
export function removeMyChannels (id) {
    return req({
        url: `${ url.USER_CHANNELS }/${ id }`,
        method: 'DELETE',
    });
}
